package com.atguigu.tingshu.user.config;

import cn.binarywang.wx.miniapp.api.WxMaService;
import cn.binarywang.wx.miniapp.api.impl.WxMaServiceImpl;
import cn.binarywang.wx.miniapp.config.impl.WxMaDefaultConfigImpl;
import jakarta.annotation.Resource;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class WxLoginConfig {

    @Resource
    private WxProperties wxProperties;

    @Bean
    public WxMaService wxMaService(){

        WxMaDefaultConfigImpl config = new WxMaDefaultConfigImpl();
        config.setAppid(wxProperties.getAppid());
        config.setSecret(wxProperties.getSecret());
        config.setMsgDataFormat("json");

        WxMaServiceImpl service = new WxMaServiceImpl();
        service.setWxMaConfig(config);

        return service;
    }
}
